(DemoLib@#WireListModel) metaclass description: (Text from: 'This is tutorial application to help people learn SmalltalkAgents™. It is based on an MVC example that appeared in the Tektronix™ versions of Smalltalk. See class method "NOTES" for use description and discussion.' styleRuns:((ScrapStyle basicNew: 0) storageSize: 22; storageFromHexString: '000100000000000C000A000100000009000000000000'))!
Some notes about this application....... by R. L. Peskin 7/93
The WireListModel is a tutorial application for SmalltalkAgents™. I first encountered this as a tutorial for the MVC paradigm common in earlier versions of Smalltalk, namely in Tektronix™ Smalltalk. The application is a "take off" on the traveling salesman problem. The user selects a set of points via mouse clicks. The objective is to reorder the points so that the total distance between points is a minimum. This problem (with applications to salesmans'' routes and to wire routing on circuit boards) is known to be NP Complete; i.e. there is no deterministic solution computable in polynomial time. The approach taken here is a ''stochastic'' one. We will randomly interchange points until (hopefully) we attain the desired minimum. There are, of course, problems with this approach. There is no way of telling in advance how many random trials are needed to get the minimum. Also, any minmum attained by this method is not guaranteed to be a true minimum; the stochastic system may relax to an intermediate state (i.e. a false minimum), and external preturbations (e.g. moving one of the points will be required) if the system is to proceed towards its true minimum.
Some caveats
In order to keep this demo application simple, some "hacks" were done in WireListWindow to avoid adding more components than necessary. See our DESolver demo for a complete window example.
Our category choices were made to help ease the learning process; they do not conform to the conventions used in other Smalltalk systems.
The decision to place drawing methods in the WireList class is based on the decision that these are primarily geometric operations using the data, not generic display opeations. Others may disagree.
Distance between point methods (Euclidean distance) are usually found in class Point. In STA class Point is special, it refers to Macintosh type points. We have begun to develop class co-ordinate, which will include such functions, but we chose not to use this here in order to keep the demo self contained. (See the TurtleGraphics class we will place on the QKS ftp site.)
We will also put a class Random, a Stream subclass on the ftp site. Again for this demo we do not use this, but rather generate random numbers using the class Float random method.
We chose to reference the WireList as an instance variable of the application (WireListModel), because we feel that the "nerve center" should control access its "models" (computations and data) and its views (windows). Another choice would be to have the WireListWindow acess the WireList directly; this might ease the fileIn problem at the expense of less code clarity.”' styleRuns:((ScrapStyle basicNew: 0) storageSize: 82; storageFromHexString: '000400000000000B000900040100000900000000000000000005000B0009000400000009000000000000000004F7000B000900040400000900000000000000000504000B0009000400000009000000000000'))!
(DemoLib@#WireListModel methodAt: #'initializeModule') description: ('Here we do a minimum initialization; only creating a QUIT item in the FIleMenu').!
DemoLib@#WireListModel compileMethodSource: (
Text from: 'launch
"Sending the method ''launch'' to the class WireListModel will result in the superclass
(ApplicationModule>>launch) method being executed. This latter class method will call
this Instance method. The Window will also have its instance variable, ''module'' asigned
as a result of this launch"
"Create the window instance, label it, and open it"